package com.etong.frame.directive;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.etong.frame.directive.checker.CheckerGroup;
import com.etong.frame.directive.deliver.DeliverGroup;
import com.etong.frame.directive.util.CommonStatus;

public class DefaultDirective implements Directive, DirectiveConfig {
	private final static Logger logger = LoggerFactory
			.getLogger(DefaultDirective.class);

	protected final static CommonStatus execError = new CommonStatus();

	// 指令配置
	private DirectiveConfig directiveConfig;
	// 检查器
	private CheckerGroup checkerGroup;
	// 分发器
	private DeliverGroup deliverGroup;

	/**
	 * 创建一个新的实例 DefaultDirective.
	 * 
	 * @param directiveConfig
	 *            指令配置信息
	 */
	public DefaultDirective(DirectiveConfig directiveConfig) {
		this.directiveConfig = directiveConfig;
	}

	/**
	 * @Title : initDirective
	 * @Description : 初始化指令
	 * @params
	 * @return 设定文件
	 * @return boolean 返回类型
	 * @throws
	 */
	public boolean initDirective() {
		logger.error("Init no implements");
		return false;
	}

	public DirectiveConfig getDirectiveConfig() {
		return directiveConfig;
	}

	public void setDirectiveConfig(DirectiveConfig directiveConfig) {
		this.directiveConfig = directiveConfig;
	}

	public boolean isBatch() {
		return false;
	}

	@Override
	public Directive buildBatch(Map<String, Object> vars) {
		if (isBatch()) {
			logger.error("Build batch no implenments");
		}
		return null;
	}

	@Override
	public String getName() {
		return directiveConfig.getName();
	}

	public CheckerGroup getCheckerGroup() {
		return checkerGroup;
	}

	public void setCheckerGroup(CheckerGroup checkerGroup) {
		this.checkerGroup = checkerGroup;
	}

	public DeliverGroup getDeliverGroup() {
		return deliverGroup;
	}

	public void setDeliverGroup(DeliverGroup deliverGroup) {
		this.deliverGroup = deliverGroup;
	}

	public CommonStatus buildDirective(Map<String, Object> vars) {
		logger.error("Build batch no implenments");
		return null;
	}

	@Override
	public String getOuputName() {
		return directiveConfig.getOuputName();
	}

	@Override
	public Boolean isOutput() {
		return directiveConfig.isOutput();
	}

	@Override
	public Boolean isOutputNext() {
		return directiveConfig.isOutputNext();
	}

	@Override
	public Integer getOutputFormat() {
		return directiveConfig.getOutputFormat();
	}

	@Override
	public String getOutputChecker() {
		return directiveConfig.getOutputChecker();
	}

	@Override
	public CommonStatus execute(Map<String, Object> vars) {
		logger.error("Execute no implenments");
		return null;
	}

	@Override
	public String getStatementConfig() {
		return "";
	}

	public CommonStatus execute(Map<String, Object> vars,
			GroupConfig groupConfig) {
		// 子类实现
		return null;
	}

}
